package com.lrkj.common.core.domain;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.lrkj.common.constant.OrgConstants;
import com.lrkj.common.core.domain.entity.OrgTree;
import com.lrkj.common.core.domain.entity.RepairProject;
import com.lrkj.common.core.domain.entity.ReportVo;
import com.lrkj.common.utils.StringUtils;

import java.io.Serializable;
import java.util.List;
import java.util.stream.Collectors;

/**
 * Treeselect树结构实体类
 *
 * @author ruoyi
 */
public class TreeSelectUp implements Serializable {
    private static final long serialVersionUID = 1L;

    /**
     * 节点ID
     */
    private String id;

    /**
     * 节点名称
     */
    private String label;

    //模块
    private String modelType;

    /**
     * 子节点
     */
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    private List<TreeSelectUp> children;

    public TreeSelectUp() {

    }

    public TreeSelectUp(OrgTree dept) {
        this.id = dept.getId();
        this.label = dept.getName();
        this.modelType = dept.getModelType();
        if (dept.getModelType().equals(OrgConstants.room)) {
            if (StringUtils.isNotEmpty(dept.getOwnerName())) {
                this.label = dept.getName() + "[" + dept.getOwnerName() + "]";
            }
        }
        this.children = dept.getChildren().stream().map(TreeSelectUp::new).collect(Collectors.toList());
    }

    public TreeSelectUp(ReportVo model) {
        this.id = model.getId();
        this.label = model.getName();
        this.modelType = model.getModelType();
        this.children = model.getChildren().stream().map(TreeSelectUp::new).collect(Collectors.toList());
    }

    public TreeSelectUp(RepairProject model) {
        this.id = model.getId();
        this.label = model.getProjectName();
        this.children = model.getChildren().stream().map(TreeSelectUp::new).collect(Collectors.toList());
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getLabel() {
        return label;
    }

    public void setLabel(String label) {
        this.label = label;
    }

    public List<TreeSelectUp> getChildren() {
        return children;
    }

    public void setChildren(List<TreeSelectUp> children) {
        this.children = children;
    }

    public String getModelType() {
        return modelType;
    }

    public void setModelType(String modelType) {
        this.modelType = modelType;
    }
}
